package com.thomsonreuter.search.compare.filter;

import com.thomsonreuter.search.compare.config.PropertyConfig;
import com.thomsonreuter.search.compare.constants.CompareConstants;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class FieldFilterHelper {
    private static FieldFilterHelper helper = null;
    private FieldFilterHelper(){}
    public static FieldFilterHelper getInstance(){
        if(helper == null){
            helper = new FieldFilterHelper();
            helper.init();
        }
        return helper;
    }

    private Map<String, String> fieldMap = new HashMap<>();

    private void init(){
        String fields = PropertyConfig.getInstance().getProperties(CompareConstants.IGNORED_FILEDS);
        if(fields == null){
            return;
        }
        Arrays.asList(fields.split(",",-1)).stream().forEach(s -> fieldMap.put(s,s));
    }

    public boolean ignoredField(String field){
        return fieldMap.containsKey(field);
    }
}
